#pragma once

#include <boost\tokenizer.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>

#include <string>
#include <math.h>
#include <vector>

typedef boost::tokenizer<boost::char_separator<char>> tokeniz;

using namespace  boost::uuids;

namespace Network
{
	///-------------------------------------------------------------------------------------------------
	/// <summary>	A helper class. </summary>
	///
	/// <remarks>	Adrian, 31/08/2015. </remarks>
	///-------------------------------------------------------------------------------------------------

	class HelperClass
	{
	public:

		///-------------------------------------------------------------------------------------------------
		/// <summary>	Parse string sentence. </summary>
		///
		/// <remarks>	Adrian, 31/08/2015. </remarks>
		///
		/// <param name="toParse">		  	to parse. </param>
		/// <param name="splittingString">	The splitting string. </param>
		/// <param name="output">		  	The output. </param>
		///-------------------------------------------------------------------------------------------------

		static void ParseStringSentence(std::string toParse, std::string splittingString, std::string output[])
		{
			boost::char_separator<char> sep(splittingString.c_str());
			tokeniz tok(toParse, sep);


			int index = 0;
			for (tokeniz::iterator tokIter = tok.begin(); tokIter != tok.end(); ++tokIter)
			{
				output[index] = tokIter.current_token().c_str();
				++index;
			}
		}

		static void ParseStringSentence(std::string toParse, std::string splittingString, std::vector<std::string>& output)
		{
			boost::char_separator<char> sep(splittingString.c_str());
			tokeniz tok(toParse, sep);

			for (tokeniz::iterator tokIter = tok.begin(); tokIter != tok.end(); ++tokIter)
			{
				output.push_back(tokIter.current_token().c_str());
			}
		}

		///-------------------------------------------------------------------------------------------------
		/// <summary>	Logxes. </summary>
		///
		/// <remarks>	Adrian, 31/08/2015. </remarks>
		///
		/// <param name="x">	The x coordinate. </param>
		/// <param name="a">	The double to process. </param>
		///
		/// <returns>	A double. </returns>
		///-------------------------------------------------------------------------------------------------

		static double logx(double x, double a)
		{
			return log(x) / log(a);
		}

		///-------------------------------------------------------------------------------------------------
		/// <summary>	Sets amoun time sleep. </summary>
		///
		/// <remarks>	Adrian, 31/08/2015. </remarks>
		///
		/// <param name="numberPeers">	Number of peers. </param>
		///
		/// <returns>	An int. </returns>
		///-------------------------------------------------------------------------------------------------

		static int SetAmounTimeSleep(const int& numberPeers)
		{
			return logx(numberPeers, 2) + logx(numberPeers, 2.718281828459045235);
		}
	};
}
